import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_slidable/flutter_slidable.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: DeleteTextPage(),
    );
  }
}

class DeleteTextPage extends StatefulWidget {
  const DeleteTextPage({Key key}) : super(key: key);

  @override
  _DeleteTextPageState createState() => _DeleteTextPageState();
}

class _DeleteTextPageState extends State<DeleteTextPage> {
  final SlidableController slidableController = SlidableController();


  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView.builder(
        itemBuilder: (BuildContext context, int index) {
          return
            Slidable(
            key: Key(index.toString()),
            controller: slidableController,
            actionPane: SlidableDrawerActionPane(),
            //滑动风格
            actionExtentRatio: 0.2,
            enabled: index != index ? false : true,
            child: Container(
                height: 48,
                width: MediaQuery.of(context).size.width,
                color: Colors.green.withOpacity(0.5),
                margin: EdgeInsets.only(top: 1),
                child: Text(
                  "$index",
                  style: TextStyle(fontSize: 20),
                )),
            secondaryActions: <Widget>[
              Container(
                width: 101,
                height: 48,
                color: Color.fromRGBO(255, 64, 89, 1),
                alignment: Alignment.center,
                child: Text("删除",style: TextStyle(fontSize: 16,color: Colors.white),),
              ),
              // IconSlideAction(
              //   caption: '删除',
              //   color: Colors.red,
              //   icon: Icons.delete,
              //   onTap: (){
              //     print("删除$index");
              //   },
              // ),
            ],
          );
        },
        itemCount: 5,
      ),
    );
  }
}
